#include <iostream>
#include <string>
#include <map>
#include <vector>

class FamilyTree
{
public:
	using ChildPointerList = std::vector<FamilyTree*>;
private:
	FamilyTree* pFather;
	ChildPointerList pChildren;
	std::string name;
public:
	FamilyTree(std::string name)
	{
		this->name = name;
		this->pFather = nullptr;
	}

	std::string Name()
	{
		return this->name;
	}

	void AddChild(FamilyTree* pTree)
	{
		this->pChildren.push_back(pTree);
		pTree->pFather = this;
	}

	int Generation()
	{
		int gen = 1;
		FamilyTree* pTree = this;
		while (pTree != nullptr)
		{
			++gen;
			pTree = pTree->pFather;
		}
		return gen;
	}

	FamilyTree* Father()
	{
		return this->pFather;
	}

	FamilyTree* ChildAt(int index)
	{
		return this->pChildren.at(index);
	}

	ChildPointerList::iterator ChildrenBegin()
	{
		return this->pChildren.begin();
	}

	ChildPointerList::iterator ChildrenEnd()
	{
		return this->pChildren.end();
	}

};

FamilyTree* ReadFamilyTree(int n)
{
	int lastSpace = 0;
	std::string line;

	std::getline(std::cin, line);

	FamilyTree* pTree = new FamilyTree(line);
	FamilyTree* pCurrent = pTree;

	for (int i = 1; i < n; ++i)
	{
		std::getline(std::cin, line);
		int space = 0;
		while (line[space] == ' ')
		{
			++space;
		}

		std::string name(line.begin() + space, line.end());
		if (space > lastSpace)
		{
			FamilyTree* pChild = new FamilyTree(name);
			pCurrent->AddChild(pChild);
			pCurrent = pChild;
		}
		else if (space == lastSpace)
		{
			FamilyTree* pFather = pCurrent->Father();
			FamilyTree* pChild = new FamilyTree(name);
			pFather->AddChild(pChild);
			pCurrent = pChild;
		}
		else
		{
			int dif = lastSpace - space;
			while (dif >= 0)
			{
				pCurrent = pCurrent->Father();
				--dif;
			}
			FamilyTree* pChild = new FamilyTree(name);
			pCurrent->AddChild(pChild);
			pCurrent = pChild;
		}
		lastSpace = space;
	}

	return pTree;
}

using FamilyTreeMap = std::map<std::string, FamilyTree*>;

void CreateFamilyTreeMap(FamilyTree* pTree, FamilyTreeMap& map)
{
	if (pTree == nullptr)
	{
		return;
	}
	map[pTree->Name()] = pTree;
	for (auto it = pTree->ChildrenBegin(); it != pTree->ChildrenEnd(); ++it)
	{
		CreateFamilyTreeMap(*it, map);
	}
}


int main()
{

	//constexpr 
	const char* trueLine = "True\n";
	//constexpr 
	const char* falseLine = "False\n";

	while (true)
	{
		int n, m;
		std::cin >> n >> m;
		if (n == 0)
		{
			break;
		}

		std::string temp;
		std::getline(std::cin, temp);

		FamilyTree* tree = ReadFamilyTree(n);

		FamilyTreeMap map;
		CreateFamilyTreeMap(tree, map);

		for (int i = 0; i < m; ++i)
		{
			std::string name1, name2, relation, temp;
			std::cin >> name1;
			std::cin >> temp >> temp >> relation;
			std::cin >> temp >> name2;
			name2 = std::string(name2.begin(), name2.end() - 1);//删除最后一个句号

			FamilyTree* node1 = map[name1];
			FamilyTree* node2 = map[name2];

			switch (relation[0]) // 目前的关系的首字母都不相同, 暂且用首字母来判断
			{
			case 'c': // child
			{
				if (node1->Father() == node2)
				{
					std::cout << trueLine;
				}
				else
				{
					std::cout << falseLine;
				}
				break;
			}
			case 'p': // parent
			{
				if (node2->Father() == node1)
				{
					std::cout << trueLine;
				}
				else
				{
					std::cout << falseLine;
				}
				break;
			}
			case 's': // sibling
			{
				if (node1 == node2)
				{
					std::cout << trueLine;
					break;
				}
				if (node2->Father() == node1->Father())
				{
					std::cout << trueLine;
				}
				else
				{
					std::cout << falseLine;
				}
				break;
			}
			case 'a': // ancestor
			{
				bool found = false;
				if (node1 == node2)
				{
					std::cout << trueLine;
					break;
				}
				FamilyTree* pt = node2->Father();
				while (pt != nullptr)
				{
					if (pt == node1)
					{
						found = true;
						break;
					}
					pt = pt->Father();
				}
				if (found)
				{
					std::cout << trueLine;
				}
				else
				{
					std::cout << falseLine;
				}
				break;
			}
			case 'd': // descendant
			{
				bool found = false;
				if (node1 == node2)
				{
					std::cout << trueLine;
					break;
				}
				FamilyTree* pt = node1->Father();
				while (pt != nullptr)
				{
					if (pt == node2)
					{
						found = true;
						break;
					}
					pt = pt->Father();
				}
				if (found)
				{
					std::cout << trueLine;
				}
				else
				{
					std::cout << falseLine;
				}
				break;
			}
			default:
				std::cout << "unknown\n";
				break;
			}
		}

		std::cout << std::endl;

	}


	return 0;
}